/*
* pps-cloud
*/
package com.pitop.payment.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

import com.pitop.payment.api.PaymentTermFeignApi;
import com.pitop.core.exceptions.PaymentTermException;
import com.pitop.core.exceptions.BaseException;
import com.pitop.core.entity.Page;
import com.pitop.payment.entity.PaymentTerm;


/**
 * 支付方式
 * @author berton
 */
@Service("paymentTermSVImpl")
@Slf4j
public class PaymentTermSVImpl {

    @Autowired
    private PaymentTermFeignApi paymentTermFeignApi;

    /**
     * 加载一个对象PaymentTerm
     * @param id * @param code 编码
     * @return PaymentTerm
     */
    public PaymentTerm load(java.lang.Long id,java.lang.String code) {
        if(id==null&&code==null){
            throw new PaymentTermException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        return paymentTermFeignApi.load(id,code);
    }
    /**
     * 加载一个对象PaymentTerm 通过id
     * @param id 
     * @return PaymentTerm
     */
    public PaymentTerm loadById(java.lang.Long id) {
        if(id==null){
            throw new PaymentTermException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        return paymentTermFeignApi.loadById(id);
    }

    /**
     * 加载一个对象PaymentTerm 通过code
     * @param code 编码
     * @return PaymentTerm
     */
    public PaymentTerm loadByCode(java.lang.String code) {
        if(code==null){
            throw new PaymentTermException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        return paymentTermFeignApi.loadByCode(code);
    }


    /**
     * 删除对象PaymentTerm
     * @param id * @param code 编码
     * @return PaymentTerm
     */
    
    public void delete(java.lang.Long id,java.lang.String code) {
        if(id==null&&code==null){
            throw new PaymentTermException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        paymentTermFeignApi.delete(id,code);
    }



    /**
     * 查询PaymentTerm分页
     *
     * @param paymentTerm  对象
     * @param curPage 当前页
     * @param pageSize 分页条数
     * @return List<PaymentTerm>
     */
    public List<PaymentTerm> list(PaymentTerm paymentTerm, int curPage,int pageSize) {
        return paymentTermFeignApi.list(paymentTerm, curPage,pageSize);
    }

    /**
     * 查询PaymentTerm分页
     *
     * @param id  * @param code  编码
     * @param curPage 当前页
     * @param pageSize 分页条数
     * @return List<PaymentTerm>
     */
    public List<PaymentTerm> list(java.lang.Long id,java.lang.String code,int curPage, int pageSize) {
        if (curPage < 0) {
           curPage = 1;
        }

        if (pageSize < 0) {
            pageSize = Page.limit;
        }

        PaymentTerm paymentTerm=new PaymentTerm();
        paymentTerm.setId(id);
        paymentTerm.setCode(code);

        return paymentTermFeignApi.list(paymentTerm,curPage,pageSize);
    }


    public int count(java.lang.Long id,java.lang.String code) {
        return paymentTermFeignApi.count(id,code);
    }


    public int count(PaymentTerm paymentTerm) {
        return paymentTermFeignApi.count(paymentTerm);
    }


    /**
     * 保存
     *
     * @param paymentTerm 实体
     * @throws BaseException
     */
    public void save(PaymentTerm paymentTerm) {
        if(paymentTerm==null){ throw new PaymentTermException(BaseException.BaseExceptionEnum.Ilegal_Param);}
        paymentTermFeignApi.build(paymentTerm);
    }

    /**
     * 更新
     *
     * @param paymentTerm 实体
     * @throws BaseException
     */
    public void modify(PaymentTerm paymentTerm) {
        if(paymentTerm==null){ throw new PaymentTermException(BaseException.BaseExceptionEnum.Ilegal_Param);}
        paymentTermFeignApi.modify(paymentTerm);
    }

}
